package com.xiaominfo.oss.utils;

import java.util.UUID;

/**
 * @Author lien
 * @Date 2019/12/24 16:55
 * @Description ID生成工具类（UUID去掉横线）
 **/
public class IdGen {

    /**
     * 生成不带横线的uuid
     * @return
     */
    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        String str = uuid.toString();
        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);
        return temp;
    }

    /**
     * 生成指定个数的uuid
     * @param number
     * @return
     */
    public static String[] getUUID(int number) {
        if (number < 1) {
            return null;
        }
        String[] ss = new String[number];
        for (int i = 0; i < number; i++) {
            ss[i] = getUUID();
        }
        return ss;
    }

    public static void main(String[] args){
        System.out.println(IdGen.getUUID());
    }
}
